import React from 'react'
// 重定向组件
import { Navigate } from 'react-router-dom'
import Login from '../views/Login'
import Home from '../views/NewsSandBox/Home'
import UserList from '../views/NewsSandBox/UserList'
import RoleList from '../views/NewsSandBox/RoleList'
import  RightList from '../views/NewsSandBox/RightList'
import NewsSandBox from '../views/NewsSandBox'

import NewsAdd from '../views/NewsSandBox/NewsManage/NewsAdd'
import NewsDraft from '../views/NewsSandBox/NewsManage/NewsDraft'
import NewsPreive from '../views/NewsSandBox/NewsManage/NewsPreive'
import NewsUpdate from '../views/NewsSandBox/NewsManage/NewsUpdate'
import NewsCategory from '../views/NewsSandBox/NewsManage/NewCategory'
import Audit from '../views/NewsSandBox/AuditManage/Audit.js'
import AuditList from '../views/NewsSandBox/AuditManage/AuditList'
import Unpublished from '../views/NewsSandBox/PublishManage/Unpublished'
import Published from '../views/NewsSandBox/PublishManage/Published'
import Sunset from '../views/NewsSandBox/PublishManage/Sunset'
import NoperMission from '../views/NewsSandBox/NoperMission/Nopermission'

// const LocalRouterMap = {
//   "/home":<Home/>,
//   "/user-manage/list":<UserList/>,
//   "/right-manage/role/list":<RoleList/>,
//   "/right-manage/right/list":<RightList/>,
//   "/news-manage/add":<NewsAdd/>,
//   "/news-manage/draft":<NewsDraft/>,
//   "/news-manage/category":<NewsCategory/>,
//   "/audit-manage/audit":<Audit/>,
//   "/audit-manage/list":<AuditList/>,
//   "/publish-manage/unpublished":<Unpublished/>,
//   "/publish-manage/published":<Published/>,
//   "/publish-manage/sunset":<Sunset/>
// }

//  function NewRouter(){
//   const [BackRouteList,setBackRouteList]=useState([])
//   useEffect(()=>{
//     Promise.all([
//       axios.get("http://localhost:8000/rights"),
//       axios.get("http://localhost:8000/children")
//     ]).then(res=>{
//       setBackRouteList([...res[0].data,...res[1].data])
//       console.log([...res[0].data,...res[1].data]);
//     })
//   },[])
//   return(
//     <Router>
//       {
//         BackRouteList.map(item=>
//           console.log(1); 
//        <Route path={item.key} key={item.key} element={LocalRouterMap[item.key]}></Route>
//        )
//       }
//     </Router>
//   )

// }

  const element=[
    {
      path:'*',
      element:<NoperMission/>
    },
    {
      path:'/login',
      element:<Login/>
    },{
      path:"/",
      element:<Navigate to="/home"/>
    },
    {
      path:'/',
      element:<NewsSandBox/>,
      children:[{
        path:'/home',
        element:(<Home/>),
      },
      {
        path:'/user-manage/list',
        element:(<UserList/>),
      },
      {
        path:'/right-manage/role/list',
        element:(<RoleList/>),
      },
      {
        path:'/right-manage/right/list',
        element:(<RightList/>),
      },
      {
        path:'news-manage/add',
        element:(<NewsAdd/>),
      },
      {
        path:'/news-manage/draft',
        element:(<NewsDraft/>),
      },
      {
        path:'/news-manage/preview/:id',
        element:(<NewsPreive/>),
      },
      {
        path:'/news-manage/update/:id',
        element:(<NewsUpdate/>),
      },
      {
        path:'/news-manage/category',
        element:(<NewsCategory/>),
      },  {
        path:'/audit-manage/audit',
        element:(<Audit/>),
      },
      {
        path:'/audit-manage/list',
        element:(<AuditList/>),
      },
      {
        path:'/publish-manage/unpublished',
        element:(<Unpublished/>),
      },
      {
        path:'/publish-manage/published',
        element:(<Published/>),
      },
      {
        path:'/publish-manage/sunset',
        element:(<Sunset/>),
      },
  
      
    ]
    }
  ]

export default element


